// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import { Button , Lazyload } from 'mint-ui'
import { Message,Dialog ,Form, FormItem,Input ,Radio} from 'element-ui'

Vue.config.productionTip = false;
Vue.component(Button.name, Button);
Vue.prototype.$message = Message;
Vue.use(Lazyload);
Vue.use(Dialog);
Vue.use(Form);
Vue.use(FormItem);
Vue.use(Input);
Vue.use(Radio);


router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.getElementById('titleText').innerHTML = to.meta.title
  }
  next()
})

Vue.directive('title', {
  inserted: function (el, binding) {
    document.title = el.innerText;
    el.remove()
  }
})
//动态设置 title  hack 微信下无法动态修改
document.setTitle = function(t) {
  document.title = t;
  var i = document.createElement('iframe');
  i.src = '//m.baidu.com/favicon.ico';
  i.style.display = 'none';
  i.onload = function() {
    setTimeout(function(){
      i.remove();
    }, 9)
  }
  document.body.appendChild(i);
}

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
